import 'doctor_patient_entity.dart' as DoctorPatientBean;

/// conversationID : "c2c_19110317495834903670542001"
/// getLastMsg : {"desc":"[其它消息]","elemType":"custom","isPeerRead":false,"isRead":false,"isSelf":true,"msgID":"144115217000318397-1604382104-3257405457","nickName":"","senderID":"20031111131047917440531001","status":2,"timestamp":1604382105,"userID":"19110317495834903670542001"}
/// type : 1
/// unreadCount : 0

class ImChatListEntity {
  String conversationID;
  GetLastMsg getLastMsg;
  int type;
  int unreadCount;

  String get patientID => getLastMsg.userID;

  DoctorPatientBean.PatientDatum patientData;

  ImChatListEntity(
      {this.conversationID, this.getLastMsg, this.type, this.unreadCount});

  ImChatListEntity.fromJson(dynamic json) {
    conversationID = json["conversationID"];
    getLastMsg = json["getLastMsg"] != null
        ? GetLastMsg.fromJson(json["getLastMsg"])
        : null;
    type = json["type"];
    unreadCount = json["unreadCount"];
  }

  Map<String, dynamic> toJson() {
    var map = <String, dynamic>{};
    map["conversationID"] = conversationID;
    if (getLastMsg != null) {
      map["getLastMsg"] = getLastMsg.toJson();
    }
    map["type"] = type;
    map["unreadCount"] = unreadCount;
    return map;
  }
}

/// desc : "[其它消息]"
/// elemType : "custom"
/// isPeerRead : false
/// isRead : false
/// isSelf : true
/// msgID : "144115217000318397-1604382104-3257405457"
/// nickName : ""
/// senderID : "20031111131047917440531001"
/// status : 2
/// timestamp : 1604382105
/// userID : "19110317495834903670542001"

class GetLastMsg {
  String desc;
  String elemType;
  bool isPeerRead;
  bool isRead;
  bool isSelf;
  String msgID;
  String nickName;
  String senderID;
  int status;
  int timestamp;
  String userID;

  GetLastMsg(
      {this.desc,
      this.elemType,
      this.isPeerRead,
      this.isRead,
      this.isSelf,
      this.msgID,
      this.nickName,
      this.senderID,
      this.status,
      this.timestamp,
      this.userID});

  GetLastMsg.fromJson(dynamic json) {
    desc = json["desc"];
    elemType = json["elemType"];
    isPeerRead = json["isPeerRead"];
    isRead = json["isRead"];
    isSelf = json["isSelf"];
    msgID = json["msgID"];
    nickName = json["nickName"];
    senderID = json["senderID"];
    status = json["status"];
    timestamp = json["timestamp"];
    userID = json["userID"];
  }

  Map<String, dynamic> toJson() {
    var map = <String, dynamic>{};
    map["desc"] = desc;
    map["elemType"] = elemType;
    map["isPeerRead"] = isPeerRead;
    map["isRead"] = isRead;
    map["isSelf"] = isSelf;
    map["msgID"] = msgID;
    map["nickName"] = nickName;
    map["senderID"] = senderID;
    map["status"] = status;
    map["timestamp"] = timestamp;
    map["userID"] = userID;
    return map;
  }
}
